<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" type="text/css" href="http://unpkg.com/view-design/dist/styles/iview.css">
    <script type="text/javascript" src="http://vuejs.org/js/vue.min.js"></script>
    <script type="text/javascript" src="http://unpkg.com/view-design@4.0.2/dist/iview.min.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="app" style="padding: 15px;">
        <Tabs active-key="key1" :animated=false>
            <Tab-pane label="helloVue" key="key1">
                <ul>
                    <li v-for="(book,index) in books">{{index}} - {{book.name}}</li>
                </ul>
            </Tab-pane>
            <Tab-pane label="v-html" key="key2">
                <span v-html="link"></span>
            </Tab-pane>
            <Tab-pane label="过滤器" key="key3">
                {{date | formatDate}}
            </Tab-pane>
            <Tab-pane label="文本框" key="key4">
                <input type="text" v-model="text">
                输入的内容是: {{text}}
            </Tab-pane>
            <Tab-pane label="单选" key="key5">
                <input type="radio" v-model="picked" value="html">html
                <input type="radio" v-model="picked" value="java">java
                <input type="radio" v-model="picked" value="js">js
                选择的是{{picked}}
            </Tab-pane>
            <Tab-pane label="多选框" key="key6">
                <input type="checkbox" v-model="checked" value="html">html
                <input type="checkbox" v-model="checked" value="java">java
                <input type="checkbox" v-model="checked" value="js">js
                选择的是: {{checked}}
            </Tab-pane>
            <Tab-pane label="下拉选" key="key7">
                <select name="" id="" v-model="selected" >
                    <option >html</option>
                    <option value="js">javascript</option>
                    <option >java</option>
                </select>
                选择的是: {{selected}}
            </Tab-pane>
        </Tabs>
    </div>

    <script>
        new Vue({
            el: '#app',
            data: {
                books: [
                    { name: ' java' },
                    { name: ' vue' },
                    { name: ' js' },
                ],
                link: '<a href="#">这是一个链接</a>',
                date: new Date(),
                text:'',
                picked:'js',
                checked:['html','java'],
                selected:['html','java'],
            },
            filters: {
                formatDate: function (value) {
                    var date = new Date(value);
                    var year = date.getFullYear();
                    var month = padDate(date.getMonth() + 1);
                    var day = padDate(date.getDate());
                    var hours = padDate(date.getHours());
                    var minutes = padDate(date.getMinutes());
                    var seconds = padDate(date.getSeconds());
                    return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
                    function padDate(value) {
                        return value < 10 ? '0' + value : value;
                    }
                },
            },
            methods: {
                padDate: function (value) {
                    return value < 10 ? '0' + value : value;
                }
            },
            mounted: function () {
                var _this = this;
                _this.timer = setInterval(function () {
                    _this.date = new Date();
                }, 1000)
            },
            beforeDestory: function () {
                var _this = this;
                if (_this.timer) {
                    clearInterval(_this.timer);
                }
            }
        });
    </script>
</body>

</html>